<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>IP地址显示</title>
    {% load staticfiles %}
    <link rel="stylesheet" type="text/css" href={% static "/css/base.css" %}>
    <link rel="stylesheet" type="text/css" href={% static "/css/changelists.css" %}>
    <link rel="stylesheet" type="text/css" href={% static "/css/responsive.css" %}>
    <script src="{% static '/jquery-1.8.3.min.js' %}"></script>
    <script>
        function show_chck(){
            var str_1 = /([0-9a-zA-Z]{4}\.){2}([0-9a-zA-Z]{4})/;
            var st = $('#index_name').val();
            alert (st);
            if (str_1.test(st)){
                $.post("http://192.168.20.155:8000/show_ip/",{'str_1':st});
                alert("添加成功");
            }
            else
                alert("错误的格式");

        }
    </script>
</head>
<body>

    <form method="get" action="/add_address/">
        <tr><input name="index_name" type="text" style="width: 20%" id="index_name" placeholder="添加MAC地址绑定：XXXX.XXXX.XXXX"></tr>
        <tr><button type="button" id="w_but" onclick="show_chck()">提交</button> </tr>
        <tr align="right" id="show_">查询了{{ number }}条数据</tr>
    </form>
    <table>
        <thead>
             <tr>
                <th>协议</th><th>IP地址</th><th>延时时间</th><th>MAC地址</th><th>类型</th><th>接口</th>
             </tr>
        </thead>

        {% for show_address in r_show_address %}
            {% if  forloop.counter|get_quyu  %}
                <tr class="row1">
                    <td>{{ show_address.protocol }}</td>
                    <td>{{ show_address.address }}</td>
                    <td>{{ show_address.min }}</td>
                    <td>{{ show_address.ip_mac }}</td>
                    <td>{{ show_address.ip_type }}</td>
                    <td>{{ show_address.interface }}</td>
                </tr>
            {% else %}
                <tr class="row2">
                    <td>{{ show_address.protocol }}</td>
                    <td>{{ show_address.address }}</td>
                    <td>{{ show_address.min }}</td>
                    <td>{{ show_address.ip_mac }}</td>
                    <td>{{ show_address.ip_type }}</td>
                    <td>{{ show_address.interface }}</td>
                </tr>
            {% endif %}
        {% endfor %}
            <tr></tr>
    </table>
</body>
</html>